home *** CD-ROM | disk | FTP | other *** search
- Path: newspost1.alt.net!usenet
- From: walth@netcom.com (Walt Howard)
- Newsgroups: comp.lang.c++
- Subject: Re: Two way communication between objects
- Date: Sun, 28 Jan 1996 12:19:28 GMT
- Organization: AltNet - Affordable Usenet Access - http://www.alt.net
- Message-ID: <4efpkq$elb@tofu.alt.net>
- References: <310ACCE2.2600@werple.mira.net.au>
- Reply-To: walth@netcom.com
- X-Newsreader: Forte Agent .99c/32.126
-
- On Sun, 28 Jan 1996 11:09:54 +1000, Ross Forder
- <erosco@werple.mira.net.au> wrote:
-
- >I have to apologise what what is probably a stupid question but I'm only
- >a beginner at some of this stuff.
- >
- >I am trying to write a VERY simple client and server set of objects. I
- >would like to client to register with the server at ctor time and have
- >the server know about the client by saving a pointer to the client
- >so he can callback to a method called say 'event'.
- >
- >The problem is the fact that they will both need a pointer to each other
- >and this seems impossible using strong typing. Is there a simple 'object
- >oriented' way to do this?
-
- You can declare a class without defining it. In this example class A
- is declared but it's definition occurs later.
-
- class A;
-
- class B
- {
- A* PointerToA;
- };
-
- class A
- {
- B* PointerToB;
- };
-
- That solves the problem about "pointers to each other" if that indeed
- was your problem.
- >
- >I have been able to make this work by having the server only know about
- >a parent class of the client (say eventhandler) but this is still not a
- >bulletproof solution.
- >
- >Can someone set me straight?
- >
- >Thanks
- >Ross Forder
-
-
-